import java.util.*;

public class Main {

    private static Scanner consola = new Scanner(System.in);
    private static long casos, vector1[], vector2[], vectorTemp[], escalar;
    private static int  dimension;
    private static StringBuffer salida = new StringBuffer("");

    public static void main(String args[]) {
        casos = consola.nextInt();
        for (int i = 0; i < casos; i++) {
            dimension = consola.nextInt();
            vectorTemp = new long[dimension];
            vector1 = new long[dimension];
            vector2 = new long[dimension];
            escalar = 0;
            for (int j = 0; j < dimension; j++) {
                vector1[j] = consola.nextLong();
            }
            for (int j = 0; j < dimension; j++) {
                vector2[j] = consola.nextLong();
            }
            Arrays.sort(vector1);
            Arrays.sort(vector2);
            for (int j = 0; j < dimension; j++) {
                vectorTemp[dimension - j - 1] = vector2[j];
            }
            vector2 = vectorTemp;

            for (int j = 0; j < dimension; j++) {
                escalar += (long) vector1[j] * (long) vector2[j];
            }
            salida.append("Case #").append(i + 1).append(": ").append(escalar).append("\n");
        }
        System.out.print(salida);
    }
}
